/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package util;

import java.io.File;

/**
 *
 * @author pyin
 */
public class WatchedFile extends File {

    public WatchedFile(String path) {
        super(path);
    }

    @Override
    public int hashCode() {
        if (this.isDirectory()) {
            int hashcode = this.getAbsolutePath().hashCode();
            String[] children = this.list();
//            System.out.println(this.getAbsolutePath());
            for(int i=0;i<children.length;i++){
                WatchedFile file = new WatchedFile(this.getAbsolutePath() + "\\" + children[i]);
                hashcode += file.hashCode();
            }
            return hashcode;
        } else {
            return (int)(this.getAbsolutePath().hashCode() + this.length() + this.lastModified());
        }
    }
}
